package com.model;


import java.sql.Date;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Map;

import org.apache.catalina.Session;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.util.DB;
import com.model.*;



public class product {
	
	
	private Integer prodid;
	public Integer getProdid() {
		return prodid;
	}
	public void setProdid(Integer prodid) {
		this.prodid = prodid;
	}




	private String title;
	private String cond;
	private String pic;
	private String description;
	private Float start_price;
	private Float buy_itnow_price;
	private Integer quantity;
	private String duration;
	private String listingtime;
	private Date listingdate;
	private String payment_method;
	private Integer subcatid;
	private Integer id;
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}




	private String shipping_service;
	private Float shipping_cost;
	




	public Float getShipping_cost() {
		return shipping_cost;
	}
	public void setShipping_cost(Float shipping_cost) {
		this.shipping_cost = shipping_cost;
	}




	private String free_shipping;
	private String handling_time;
	
	
	
	public String getShipping_service() {
		return shipping_service;
	}
	public void setShipping_service(String shipping_service) {
		this.shipping_service = shipping_service;
	}
	
	public String getFree_shipping() {
		return free_shipping;
	}
	public void setFree_shipping(String free_shipping) {
		this.free_shipping = free_shipping;
	}
	public String getHandling_time() {
		return handling_time;
	}
	public void setHandling_time(String handling_time) {
		this.handling_time = handling_time;
	}

	
	
	
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getCond() {
		return cond;
	}
	public void setCond(String cond) {
		this.cond = cond;
	}
	public String getPic() {
		return pic;
	}
	public void setPic(String pic) {
		this.pic = pic;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Float getStart_price() {
		return start_price;
	}
	public void setStart_price(Float start_price) {
		this.start_price = start_price;
	}
	public Float getBuy_itnow_price() {
		return buy_itnow_price;
	}
	public void setBuy_itnow_price(Float buy_itnow_price) {
		this.buy_itnow_price = buy_itnow_price;
	}
	public Integer getQuantity() {
		return quantity;
	}
	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}
	public String getDuration() {
		return duration;
	}
	public void setDuration(String duration) {
		this.duration = duration;
	}
	public String getListingtime() {
		return listingtime;
	}
	public void setListingtime(String listingtime) {
		this.listingtime = listingtime;
	}
	public Date getListingdate() {
		return listingdate;
	}
	public void setListingdate(Date listingdate) {
		this.listingdate = listingdate;
	}
	public String getPayment_method() {
		return payment_method;
	}
	public void setPayment_method(String payment_method) {
		this.payment_method = payment_method;
	}
	public Integer getSubcatid() {
		return subcatid;
	}
	public void setSubcatid(Integer subcatid) {
		this.subcatid = subcatid;
	}
	
	
	
	
	
	
	public void insert()
	{
		Integer id;	
		Map session;
		session=ActionContext.getContext().getSession();
		
		String sc=(String)session.get("subcatid");
		id=(Integer)session.get("id");
		
		Integer subcatid=Integer.parseInt(sc);
		System.out.println("Injava model class scid is"+subcatid);
		System.out.println("Injava model class condition is"+cond);
		
		
		String insertQuery = "insert into product "
			+ "(title, cond,pic,description,start_price,buy_itnow_price,quantity,duration,listingtime,listingdate,payment_method,subcatid,id) " + "values('"+ title
			+ "', '" + cond + "', '"+null+"','" +description+ "'," + start_price+ "," +buy_itnow_price+ ", " +quantity+ ", '" + duration+ "','" + listingtime+ "',"+listingdate+",'"+payment_method+"',"+subcatid+","+id+");";
		
		
		
		 DB.update(insertQuery);
		
	}
	
	
	

	public void insert1(int prodid)
	{
		Integer id;
		

		Map session;
		session=ActionContext.getContext().getSession();
        id=(Integer)session.get("id");
        
		System.out.println("The id is"+id);
		


		String query="insert into shipping(shipping_service,shipping_cost,free_shipping,handling_time,prodid,id) values('"+shipping_service+"',"+shipping_cost+",'"+free_shipping+"','"+handling_time+"',"+prodid+","+id+");";
		 DB.update(query);
		
	}
	
	
	
	
	
	
	
	
	

}
